package com.crazyread.imple;





import com.crazyread.dao.UserAuthorityMapper;
import com.crazyread.dao.UserMapper;
import com.crazyread.model.domain.Authority;
import com.crazyread.model.domain.User;
import com.crazyread.model.domain.UserAuthority;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserServiceImpl  {
    @Autowired
    UserMapper userMapper;
    @Autowired
    UserAuthorityMapper userAuthorityMapper;
    //获取用户信息
    public User selectUser(String username){
        User user = userMapper.selUserByUsername(username);
        return user;
    }
    //获取用户权限
    public Authority selectAuthorityByUserId(Long id){
        UserAuthority userAuthority = userAuthorityMapper.getUserAuthority(id);
        Authority authority = userMapper.selAuthorityById(userAuthority.getAuthorityId());
        return authority;
    }

    //删除用户
    public void delUser(int id){
        userMapper.delUser(id);
        userAuthorityMapper.delUserAuthority(id);
    }
    //修改用户
    public void updateUser(User user){
        userMapper.updateUser(user);
    }





}
